package com.chentf;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * @author chentengfei
 * @desc ...
 * @date 2021-09-20 13:44:53
 */
@SpringBootApplication  //代表springboot应用
@EnableDiscoveryClient  //代表服务注册中心客户端   consul  client
@EnableCircuitBreaker   //开启hystrix服务熔断
//@EnableHystrix  //开启hystrix服务熔断
public class HystrixApplication {

    private static final Logger log = LoggerFactory.getLogger(HystrixApplication.class);

    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(HystrixApplication.class, args);
        ConfigurableEnvironment environment = run.getEnvironment();
        String port = environment.getProperty("server.port");
        String projectName = environment.getProperty("spring.application.name");
        log.info("端口号:{},项目名称:{}",port,projectName);
    }
}
